<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./vue.js"></script>
</head>
<body>
<div id="root">
    <button @click="fn">点我</button>
        <p>{{str}}</p>
        <p>{{num}}</p>
</div>
</body>
<script>
    new Vue({
        el: '#root',
        data: {
            str:"明年开春了",
            num:0,
            obj:{
                username:"zs",
                age:18
            }
        },
        methods:{
            fn(){
                this.str+="!";
                this.num++;
            }
        },
        watch:{
            str(){
                console.log(this.str);
            },
            num(newv,oldv){
                console.log(this.num,newv,oldv);
            }
        }
    })
</script>
</html>